<?php 
header("Content-type: text/html; charset=utf-8");

/**
 * [D description]
 * @Author   Xuebingsi
 * @DateTime 2017-09-07T09:07:26+0800
 */
function D()
{
	echo "这个是我自己封装的函数";
}

/**
 * [Ftime 日期格式化函数]
 * @Author   Xuebingsi
 * @DateTime 2017-09-07T08:50:28+0800
 * @param    [int]                   $time [时间戳]
 */
function Ftime($time)
{
	$diff = time()-$time;

	if($diff<60){
		return "刚刚";
	}elseif($diff<3600){
		return floor($diff/60)."分钟前";
	}elseif($diff<86400){
		return floor($diff/3600)."小时前";
	}elseif($diff<(86400*7)){
		return floor($diff/86400)."天前";
	}else{
		return date("Y-m-d H:i:s",$time);
	}
}

/**
 * [getNonceStr 获取随机字符串]
 * @Author   Xuebingsi
 * @DateTime 2017-09-12T09:14:38+0800
 * @param    integer                  $num [数量]
 * @return   [字符串]                        [返回字符串]
 */
function getNonceStr($num=16)
{
	$temp = "";
	$str ="QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890";

	for ($i=0; $i < $num; $i++) { 
		$temp .= $str[mt_rand(0,strlen($str)-1)];
	}

	return $temp;
}

/**
 * [config 获取配置]
 * @Author   Xuebingsi
 * @DateTime 2017-09-25T08:30:13+0800
 * @param    [type]                   $key [配置项]
 * @return   [type]                        [配置项对应的值]
 */
function config($key)
{
	$configs = include CONF_PATH.'/config.php';

	return isset($configs[$key]) ? $configs[$key] : "该配置项不存在";
}

function db($table)
{
	return new Model($table);
}













 ?>